﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>WEB打印控件LODOP的样例三十五:获得打印结果和程序代码</title>

<script language="javascript" src="LodopFuncs.js"></script>
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
	<embed id="LODOP_EM" TYPE="application/x-print-lodop" width=0 height=0 PLUGINSPAGE="install_lodop32.exe"></embed>
</object> 
</head>
<body>

<h2><font color="#009999">演示如何获得打印结果和程序代码：</font>
</h2>
<p>&nbsp;&nbsp;&nbsp;  
一般情况下，打印设计的程序代码需要用界面的“生成程序代码”菜单命令生成后，手工复制</p>  <p>出来融合到页面程序中使用。但实际上无论是<font color="#0000FF">直接打印、打印预览、打印维护</font>还是<font color="#0000FF">打印设计</font>，&nbsp;</p>  <p>
在运行结束或关闭窗口时都会返回相应的执行结果：</p>    
<p><font color="#0000FF">直接打印</font><font color="#000000">返回逻辑真假结果（1或true代表真，false或0代表假），表示是否成功（关于进一步捕获打印状态<a href="PrintSample45.html">参考样例45</a>）；</font></p>  


<p><font color="#0000FF">打印维护</font><font color="#000000">和</font><font color="#0000FF">打印预览</font><font color="#000000">返回打印次数，大于0表示打印成功的次数；</font></p>  


<p><font color="#0000FF">打印设计</font><font color="#000000">窗口关闭后会自动生成程序代码并返给页面，页面程序可以进一步验证这些代码或提交保存；</font></p>  


<p><font size="2"><input type="button" value="打印预览" onclick="prn1_preview()">
<input type="button" value="打印维护" onclick="prn1_setup()">
<input type="button" value="打印设计" onclick="prn1_design()">
<input type="button" value="打印维护返回程序代码" onclick="prn2_setup()">
</font>

<form method="POST" action="--WEBBOT-SELF--">
  <p><textarea rows="12" id="S1" cols="107" >返回的结果值</textarea><font size="2">
<div id='id01' style="display:none">
  <input type="button" value="用这些代码执行打印预览" id="button02"   onclick="prn2_Preview()"> 
  <input type="button" value="保存这些代码到本地文件" id="button03" onclick="myWriteFile(document.getElementById('S1').value)"> 
  <input type="button" value="把程序代码导入进来" id="button04" onclick="document.getElementById('S1').value=myReadFile()"> 
  <input type="button" value="用这些代码执行设计并返回结果(循环互动)" id="button05"   onclick="prn2_design()"> 
</div>
</font>

</form>


<p><font size="2"><br>
</font>

<p><a href="PrintSampIndex.html">&lt;&lt;回样例目录</a></p>

<script language="javascript" type="text/javascript"> 
	var LODOP; //声明为全局变量 
	function prn1_preview() {	
		CreateOneFormPage();	
		document.getElementById('S1').value=LODOP.PREVIEW();
		document.getElementById('id01').style.display="none";	
	};
	function prn1_setup() {		
		CreateOneFormPage();
		document.getElementById('S1').value=LODOP.PRINT_SETUP();
		document.getElementById('id01').style.display="none";		
	};
	function prn1_design() {		
		CreateOneFormPage();
		document.getElementById('S1').value=LODOP.PRINT_DESIGN();
		document.getElementById('id01').style.display=""; 	
	};
	function prn2_setup() {		
		CreateOneFormPage();
		LODOP.SET_PRINT_MODE("PRINT_SETUP_PROGRAM",true);
		document.getElementById('S1').value=LODOP.PRINT_SETUP();
		document.getElementById('id01').style.display="";		
	};	
	function prn2_Preview() {		
		LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM')); 		
		eval(document.getElementById('S1').value); 
		LODOP.PREVIEW();
	};
	function prn2_design() {		
		LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM')); 		
		eval(document.getElementById('S1').value); 
		document.getElementById('S1').value=LODOP.PRINT_DESIGN();
	};		
	function CreateOneFormPage(){
		LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM')); 
		LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_获得程序代码");
		LODOP.ADD_PRINT_TEXTA("htm-1",12,228,317,30,"关闭本设计窗口会看到程序代码");
		
LODOP.SET_PRINT_STYLEA(0,"FontSize",15);
		LODOP.ADD_PRINT_ELLIPSE(168,29,100,60,0,1);
		LODOP.ADD_PRINT_BARCODE(190,483,213,60,"128A","123456789012");
		LODOP.SET_PRINT_STYLEA(0,"Color","#FF00FF");
		LODOP.ADD_PRINT_CHART(296,42,604,185,1,"");
		LODOP.ADD_PRINT_SHAPE(4,51,195,239,128,0,1,"#0080FF");
		LODOP.ADD_PRINT_HTM(141,377,261,161,"<!DOCTYPE>\n<style>table,td{border:1px solid black;}</style>\n<body margin=0 style=\"background-color:transparent;\" >\n<table>\n<tr>\n<td>透明超文本表格</td>\n<td>预览就看出透明</td>\n<td>预览才看出透明</td>\n</tr>\n<tr>\n<td>非表格也能透明</td>\n<td>预览看出透明</td>\n<td>预览看出透明</td>\n</tr>\n</table>");

	};
	function myWriteFile(strText) {
		var strFilename=LODOP.GET_DIALOG_VALUE("LocalFileFullName","保存的新文件名.txt")
	 	if (LODOP.WRITE_FILE_TEXT(0,strFilename,strText)=="ok")
		   {alert("写入成功！");} else {alert("写入失败！");}
	};
	function myReadFile() {
		var strFilename=LODOP.GET_DIALOG_VALUE("LocalFileFullName","导入的文件名.txt")		
		return LODOP.GET_FILE_TEXT(strFilename);
	};	
</script> 




</body>
</html>